package com.yupi.longojbackendquestionservice.controller.inner;

import com.yupi.longojbackendmodel.entity.Question;
import com.yupi.longojbackendmodel.entity.QuestionSubmit;
import com.yupi.longojbackendquestionservice.service.QuestionService;
import com.yupi.longojbackendquestionservice.service.QuestionSubmitService;
import com.yupi.longojbackendserviceclient.service.QuestionFeignClient;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;

    /**
     * 根据id获取题目
     * @param questionId
     * @return
     */
    @Override
    @GetMapping("/get/id")
   public Question qusetionById(@RequestParam("questionId") Long questionId){

        return questionService.getById(questionId);
    }


    @Override
    @GetMapping("/question_submit/get/id")
  public   QuestionSubmit questionSubmitById(@RequestParam("questionSubmitId") Long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }


    @Override
    @PostMapping("/question_submit/update")
   public Boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
       return questionSubmitService.updateById(questionSubmit);
    }
}
